﻿@model NAccounting.Models.ClosePeriodsModel
@{
    ViewBag.Title = "ClosePeriod";
}

<script language="javascript">
    $(function () {
        $("#messageContainer").messageContainer();

        var closePeriodUrl = '@Url.Action("CloseDate")';

        $(".closePeriodButton").click(function () {
            $('#selectedDate').val($(this).attr('date-reference'));
            $('form').submit();
            return false;
        });
    });
</script>

<style>
    
    th
    {
        font-size:13px;
    }
    
    td, th
    {
        border-bottom: 1px solid #999;
        padding:3px;
    }
    
    .content-right h3
    {
        border-bottom:0 !important;
        margin:0 !important;
    }
    
    .borderLeft
    {
        border-left: 1px solid #999;
        text-align:left;
    }
    
    .borderTop
    {
        border-top: 1px solid #999;
    }
    
    .borderRight
    {
        border-right: 1px solid #999;
        }
</style>

<div class="content-left">
    @Html.Partial("ContentLeftPartial")
</div>

@using (Html.BeginForm())
{ 
@Html.Hidden("selectedDate");

<div class="content-right">
    <h2>Index</h2>
    <h3>Períodos Pendentes de fechamento</h3>
    <div>
        * C - Indica que os valores de créditos são superios ao de débitos
    </div>
    <div>
        * D - Indica que os valores de débitos são superios ao de créditos
    </div>
    <table cellpadding="1" cellspacing="0" width="100%">
        <tr>
            <th>&nbsp;</th>
            <th>&nbsp;</th>
            <th class="borderLeft borderTop borderRight">Lotes em aberto</th>
        </tr>
        @foreach (var lotByDate in Model.LotsByDate) {
            var enableClosePeriod = lotByDate.Lots.Count() > 0 ? "disabled" : "";
            <tr>
                <td width="20" class="borderLeft"><button class="closePeriodButton" date-reference="@lotByDate.Date" @enableClosePeriod>Fechar</button></td>
                <td>@lotByDate.Date</td>
                <td class="borderLeft borderRight">&nbsp;</td>
            </tr>
            foreach(var lot in lotByDate.Lots)
            {
                <tr>
                    <td class="borderLeft">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td class="borderLeft borderRight">
                        @Html.ActionLink(lot.Description, "Edit", new { Id = lot.Id }) @lot.Value (@lot.DivergenceType)
                    </td>
                </tr>
            }
        }
    </table>
    <div>
        * C - Indica que os valores de créditos são superios ao de débitos
    </div>
    <div>
        * D - Indica que os valores de débitos são superios ao de créditos
    </div>
    <p>&nbsp;</p>
</div>
}